package mt.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;



public class ConfigUtil {
	public static Properties getPropertyFromFile(String file) {
		
		InputStream inputStream = null;
		String fullFile = PathUtil.getWSDLFilePathInWebInf(file);
		
		Properties p = new Properties();
		try {
			inputStream = new FileInputStream(new File(fullFile));	
			p.load(inputStream);
		} catch (FileNotFoundException e) {
			throw new IllegalArgumentException("Properties file not found: " + fullFile);
		} catch (IOException e) {
			throw new IllegalArgumentException("Properties file can not be loading: " + fullFile);
		}
		finally {
			try {if (inputStream != null) inputStream.close();} catch (IOException e) {e.printStackTrace();}
		}
		if (p == null)
			throw new RuntimeException("Properties file loading failed: " + fullFile);

		return p;
	}
}
